#[test]
fn test_binary_heap_new_free() {
    let mut heap = binary_heap_new(BinaryHeapType::Min, int_compare);
    for i in 0..NUM_TEST_VALUES {
        test_array[i] = i;
        assert!(binary_heap_insert(&mut heap, &mut test_array[i]) != 0);
    }
    assert!(binary_heap_num_entries(&heap) == NUM_TEST_VALUES);
    binary_heap_free(heap);
}
#[test]
fn test_min_heap() {
    unsafe {
        let heap = binary_heap_new(BINARY_HEAP_TYPE_MAX, int_compare);
        for i in 0..NUM_TEST_VALUES {
            test_array[i] = i as i32;
            assert!(binary_heap_insert(heap, &test_array[i]) != 0);
        }
        let mut i = NUM_TEST_VALUES as i32;
        while binary_heap_num_entries(heap) > 0 {
            let val = binary_heap_pop(heap);
            assert!(*val == i - 1);
            i = *val;
        }
        binary_heap_free(heap);
    }
}
#[test]
fn test_out_of_memory() {
    let values = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0];
    unsafe {
        HEAP = binary_heap_new(0, int_compare);
        alloc_test_set_limit(0);
        for i in 0..16 {
            assert!(binary_heap_insert(HEAP, &values[i] as *const _ as *const libc::c_void) != 0);
        }
        assert!(binary_heap_num_entries(HEAP) == 16);
        for i in 0..16 {
            assert!(binary_heap_insert(HEAP, &values[i] as *const _ as *const libc::c_void) == 0);
            assert!(binary_heap_num_entries(HEAP) == 16);
        }
        for i in 0..16 {
            let value = binary_heap_pop(HEAP);
            assert!(*value == i);
        }
        assert!(binary_heap_num_entries(HEAP) == 0);
        binary_heap_free(HEAP);
    }
}
fn main() {
    run_tests(tests);
    println!("num_assert: {}", num_assert);
}
